package com.taomu.app.zongchouhuli.utils.banner;

import com.taomu.app.zongchouhuli.moudle.index.entity.BannerEntity;
import com.youth.banner.Banner;
import com.youth.banner.Transformer;

import java.util.ArrayList;
import java.util.List;

public class BannerNewsWapper {
    private Banner mBanner;

    private List<BannerEntity> mItemList = new ArrayList<>(4);

    public BannerNewsWapper(Banner banner) {
        mBanner = banner;
        createBannerData();
        initBanner();
    }

    private void createBannerData() {
        mItemList.add(new BannerEntity());
    }

    private void initBanner() {
        //初始化轮播
        mBanner.setImageLoader(new CustomViewLoader());
        mBanner.setImages(mItemList);
        //设置banner动画效果
        mBanner.setBannerAnimation(Transformer.Default);
        //设置自动轮播，默认为true
        mBanner.isAutoPlay(true);
        //设置轮播时间
        mBanner.setDelayTime(5000);
        //设置指示器位置（当banner模式中有指示器时）
        mBanner.setIndicatorGravity(com.youth.banner.BannerConfig.NOT_INDICATOR);
        mBanner.start();
    }

    public void setDatas(List<BannerEntity> itemList) {
        mBanner.update(itemList);
    }

    public void stopAuto() {
        mBanner.stopAutoPlay();
    }

    public void startAuto() {
        mBanner.startAutoPlay();
    }
}
